<?php

use yii\widgets\ActiveForm;
use backend\models\Permission;
use backend\models\GroupPermission;
/* @var $this yii\web\View */
/* @var $model app\models\Group */

$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Groups', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-form">    
    <p>Nhóm : <?=$model->name ?></p>   
     <?php 
        $form = ActiveForm::begin([
            'options'=>['class' => 'form-horizontal', 'enctype'=>'multipart/form-data']
        ]); 
    ?> 
    <div class="canine">
        <ul class="all-checkbox">
            <li><input type="checkbox" id="all" name="check-all" /> <b> Chọn tất quyền trong hệ thống</b> </li>
            <?php 
                $premissions = Permission::loadArrayAllPermission();
                $group_permission = GroupPermission::getArrayPermissionOfGroup($model->id);
                $m=1;
                if(count($premissions)>0){
                    foreach ($premissions as $pre){?>
            <li class="parent-list col-lg-4">
                <input type="checkbox" value="<?=$pre['id']?>" name="checkbox[]" class="canine parent" <?= (isset($group_permission) && in_array($pre['id'], $group_permission))?' checked="checked" ':''; ?> /> <b> <?=$pre['name']?> </b> 
                <ul>
                    <?php foreach($pre['CHID'] as $c){?>
                    <li><input type="checkbox" name="checkbox[]" class="canine" value="<?=$c['id']?>" <?= (isset($group_permission) && in_array($c['id'], $group_permission))?' checked="checked" ':''; ?> /> <?=$c['name']?> </li>
                    <?php }?>
                </ul>
            </li>       
            <?php   
                        if($m%3==0){ 	    		
                            echo "<div class='clear-all'></div>"; 
                        }    
                        $m++;

                    }
                }
             
            ?>
          
           
	</ul>     
    </div>  
    <div class='clear-all'></div>
   <div class="form-group buttom-update-permission">                
        <button class="btn btn-success" type="submit">Create</button>
   </div>
    <?php ActiveForm::end(); ?>
</div>
